package com.catchman.demo;

import com.catchman.demo.domain.User;
import com.catchman.demo.service.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

@SpringBootApplication
public class DemoApplication implements ApplicationRunner {
    private static final Logger logger = LoggerFactory.getLogger(DemoApplication.class);

    @Autowired
    private UserRepository userRepository;

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        User user= userRepository.getOne(1L);
        System.out.println(user);
        System.err.println("ceshirizhi");
        logger.error("测试日志！");

       //分页查询
       Page<User> userPage= userRepository.findALLWithPageable(PageRequest.of(0,2));
       System.out.println(userPage.getSize());
    }
}
